home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / OLE_Files / VC++ / OLEShell.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  3.6 KB  |  125 lines

  1. // OLEShell.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "OLEShell.h"
  6. #include "OLEShellDlg.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // COLEShellApp
  16.  
  17. BEGIN_MESSAGE_MAP(COLEShellApp, CWinApp)
  18.     //{{AFX_MSG_MAP(COLEShellApp)
  19.         // NOTE - the ClassWizard will add and remove mapping macros here.
  20.         //    DO NOT EDIT what you see in these blocks of generated code!
  21.     //}}AFX_MSG
  22.     ON_COMMAND(ID_HELP, CWinApp::OnHelp)
  23. END_MESSAGE_MAP()
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // COLEShellApp construction
  27.  
  28. COLEShellApp::COLEShellApp()
  29. {
  30.     // CG: The following line was added by the OLE Automation component.
  31.     EnableAutomation();
  32.     AfxOleLockApp();
  33.     // TODO: add construction code here,
  34.     // Place all significant initialization in InitInstance
  35. }
  36.  
  37. COLEShellApp::~COLEShellApp()
  38. {
  39.     // CG: The following line was added by the OLE Automation component.
  40.     AfxOleUnlockApp();
  41. }
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // The one and only COLEShellApp object
  45.  
  46. COLEShellApp theApp;
  47.  
  48. /////////////////////////////////////////////////////////////////////////////
  49. // COLEShellApp initialization
  50.  
  51. BOOL COLEShellApp::InitInstance()
  52. {
  53.     // Initialize OLE libraries
  54.     if (!AfxOleInit())
  55.     {
  56.         AfxMessageBox(IDP_OLE_INIT_FAILED);
  57.         return FALSE;
  58.     }
  59.  
  60.     // Standard initialization
  61.     // If you are not using these features and wish to reduce the size
  62.     //  of your final executable, you should remove from the following
  63.     //  the specific initialization routines you do not need.
  64.  
  65. #ifdef _AFXDLL
  66.     Enable3dControls();            // Call this when using MFC in a shared DLL
  67. #else
  68.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  69. #endif
  70.  
  71.     // Parse the command line to see if launched as OLE server
  72.     if (RunEmbedded() || RunAutomated())
  73.     {
  74.         // Register all OLE server (factories) as running.  This enables the
  75.         //  OLE libraries to create objects from other applications.
  76.         COleTemplateServer::RegisterAll();
  77.  
  78.         // Application was run with /Embedding or /Automation.  Don't show the
  79.         //  main window in this case.
  80.         return TRUE;
  81.     }
  82.  
  83.     // When a server application is launched stand-alone, it is a good idea
  84.     //  to update the system registry in case it has been damaged.
  85.     COleObjectFactory::UpdateRegistryAll();
  86.  
  87.     COLEShellDlg dlg;
  88.     m_pMainWnd = &dlg;
  89.     int nResponse = dlg.DoModal();
  90.     if (nResponse == IDOK)
  91.     {
  92.         // TODO: Place code here to handle when the dialog is
  93.         //  dismissed with OK
  94.     }
  95.     else if (nResponse == IDCANCEL)
  96.     {
  97.         // TODO: Place code here to handle when the dialog is
  98.         //  dismissed with Cancel
  99.     }
  100.  
  101.     // Since the dialog has been closed, return FALSE so that we exit the
  102.     //  application, rather than start the application's message pump.
  103.     return FALSE;
  104. }
  105.  
  106. BEGIN_DISPATCH_MAP(COLEShellApp, CWinApp)
  107.     //{{AFX_DISPATCH_MAP(COLEShellApp)
  108.         // NOTE - the ClassWizard will add and remove mapping macros here.
  109.     //}}AFX_DISPATCH_MAP
  110. END_DISPATCH_MAP()
  111.  
  112.  
  113.  
  114. // Note: we add support for IID_IOLEShellApp to support typesafe binding
  115. //  from VBA.  This IID must match the GUID that is attached to the
  116. //  dispinterface in the .ODL file.
  117.  
  118. // {F137DAC7-B031-11D0-8F38-444553540000}
  119. static const IID IID_IOLEShellApp =
  120. { 0xf137dac7, 0xb031, 0x11d0, { 0x8f, 0x38, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } };
  121.  
  122. BEGIN_INTERFACE_MAP(COLEShellApp, CWinApp)
  123.     INTERFACE_PART(COLEShellApp, IID_IOLEShellApp, Dispatch)
  124. END_INTERFACE_MAP()
  125.